<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>03_变量的解构赋值</title>
</head>
<body>
<!--
1. 理解:
  * 从对象或数组中提取数据, 并赋值给变量(多个)
2. 对象的解构赋值
  let {n, a} = {n:'tom', a:12}
3. 数组的解构赋值
  let [a,b] = [1, 'atguigu'];
4. 用途
  * 给多个形参赋值
-->
<script type="text/javascript">
    let obj = {username: 'kobe', age: 39};
    let {username, age} = obj;
    console.log(username, age);

    let arr = [1, 2, 3, 'aaa', true];
    // let [a, b, c, d, e] = arr;
    // console.log(a, b, c, d, e);
    let [, , c, d, e] = arr;
    console.log(c, d, e);

    function foo({username,age}) {
        console.log(username, age);
    }

    foo(obj);
</script>
</body>
</html>